﻿namespace ChessToys
{
    using System.Collections.Generic;

    public static class MoveGeneratorUtils
    {
        private static IMoveGenerator MOVE_GENERATOR = new DelegatingPieceMoveGenerator();

        public static ISet<Move> PossibleMoves(Board board, Color color)
        {
            ISet<Move> moves = new HashSet<Move>();
            foreach (Position position in board)
            {
                IPiece piece = board[position];
                if (piece != null && piece.Color == color)
                {
                    moves.UnionWith(MOVE_GENERATOR.Generate(board, position));
                }
            }
            return moves;
        }
    }
}
